﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace Minestorm.Retro.GameLogic
{
    public class LevelBounds
    {
        private VertexBuffer _vertexBuffer;
        private IndexBuffer _indexBuffer;
        private GraphicsDevice _graphics;

        public LevelBounds(GraphicsDevice graphics)
        {
            _graphics = graphics;
        }

        public void Initialize()
        {
            var vertices = new VertexPositionColor[4];

            vertices[0] = new VertexPositionColor(new Vector3(Constants.Level.MinX, Constants.Level.MaxY, 0f), Constants.VectorColor);
            vertices[1] = new VertexPositionColor(new Vector3(Constants.Level.MaxX, Constants.Level.MaxY, 0f), Constants.VectorColor);
            vertices[2] = new VertexPositionColor(new Vector3(Constants.Level.MaxX, Constants.Level.MinY, 0f), Constants.VectorColor);
            vertices[3] = new VertexPositionColor(new Vector3(Constants.Level.MinX, Constants.Level.MinY, 0f), Constants.VectorColor);

            _vertexBuffer = new VertexBuffer(_graphics, VertexPositionColor.VertexDeclaration, 4, BufferUsage.WriteOnly);

            _vertexBuffer.SetData(vertices);

            _indexBuffer = new IndexBuffer(_graphics, IndexElementSize.SixteenBits, 5, BufferUsage.WriteOnly);

            _indexBuffer.SetData(new short[] { 0, 1, 2, 3, 0 });
        }

        public Matrix GetWorld()
        {
            return Matrix.Identity;
        }

        public void Draw()
        {
            //_graphics.SetVertexBuffer(_vertexBuffer);
            //_graphics.Indices = _indexBuffer;

            //_graphics.DrawIndexedPrimitives(PrimitiveType.LineStrip, 0, 0, 4, 0, 4);
        }
    }
}
